//
//  SYChuangTableViewCell.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/4/22.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYChuangTableViewCell.h"

@interface SYChuangTableViewCell ()

@property (strong, nonatomic) NSArray *nameArr;
@property (strong, nonatomic) UIButton *deleteBtn;//删除
@end


@implementation SYChuangTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubView];
    }
    return self;
}

- (void)initSubView {
    [self addSubview:self.jinXingView];
    [self.jinXingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.mas_left).offset(14);
        make.right.equalTo(self.mas_right).offset(-14);
    }];
    UILabel *contLab = nil;
    for (NSInteger i = 0; i < 6; i ++) {
        if (i == 5) {//移出按钮
            _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [_deleteBtn setImage:[UIImage imageNamed:@"sx_xiaozu_yichu"] forState:UIControlStateNormal];
            _deleteBtn.titleLabel.font = [UIFont systemFontOfSize:12];
            [_deleteBtn addTarget:self action:@selector(deleteBtnClick) forControlEvents:UIControlEventTouchUpInside];
            _deleteBtn.tag = 20+i;
            [self.jinXingView addSubview:_deleteBtn];
            [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(contLab.mas_right);
                make.top.equalTo(self.jinXingView.mas_top);
                make.width.equalTo(self.jinXingView).multipliedBy(0.167);
                make.height.mas_equalTo(40);
            }];
        } else {
            UILabel *title = [UILabel titleColour:TITLECOLOR
                                       titleFount:14
                                         pingfang:@"PingFang-SC-Medium"
                                        alignment:NSTextAlignmentCenter
                                        titleLine:1];
            [self.jinXingView addSubview:title];
            title.text = @"1234567";
            title.tag = 30+i;
            if (i == 0) {
                contLab = title;
                [title mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self.jinXingView.mas_left);
                    make.top.equalTo(self.jinXingView.mas_top);
                    make.width.equalTo(self.jinXingView).multipliedBy(0.167);
                    make.height.mas_equalTo(40);
                }];
            } else {
                [title mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(contLab.mas_right);
                    make.top.equalTo(self.jinXingView.mas_top);
                    make.width.equalTo(self.jinXingView).multipliedBy(0.167);
                    make.height.mas_equalTo(40);
                }];
                contLab = title;
            }
        }
        
    }
}
//移出
- (void)deleteBtnClick {
    
}
- (void)chuangjianTableViewIndexPath:(NSIndexPath *)indexPath {
    UIColor *color = nil;
    if (indexPath.row%2) {
        color = [UIColor colorWithHexString:@"F8F8F8"];
    } else {
        color = [UIColor whiteColor];
    }
    self.jinXingView.backgroundColor = color;
    for (NSInteger i = 0; i < 6; i ++) {
        UILabel *lab = [self viewWithTag:30+i];
        if (i == 0) {//工号
            lab.text = @"E0257";
        } else if (i == 1) {//姓名
            lab.text = @"郑相宜";
        } else if (i == 2) {//性别
            lab.text = @"女";
        } else if (i == 3) {//手机
            lab.text = @"13014518277";
        } else if (i == 4) {//添加日期
            lab.text = @"2019-5-6";
        }
    }
    
    
}
#pragma mark - set
- (UIView *)jinXingView {
    if (!_jinXingView) {
        _jinXingView = [[UIView alloc] init];
        _jinXingView.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
    }
    return _jinXingView;
}
@end

















